package com.gtq.uhome.service.serviceImpl;

import com.gtq.uhome.mapper.ConsigneeMapper;
import com.gtq.uhome.pojo.Consignee;

import com.gtq.uhome.service.AddressService;
import com.gtq.uhome.service.AddressService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * 查询用户的所有收货地址
 */
@Service("findAddressService")
public class AddressServiceImpl implements AddressService {

    @Resource
    private ConsigneeMapper consigneeMapper;//实例化

    /**
     * 查询用户收货地址
     * @param userId
     * @return
     */
    @Override
    public List<Consignee> findAddress(Integer userId) {
        return consigneeMapper.findAddress(userId);
    }

    /**
     * 添加用户收货地址
     * @param consignee
     * @return
     */
    @Override
    public Boolean addConsignee(Consignee consignee) {
        consignee.setStatusCode("0");
        return consigneeMapper.addConsignee(consignee)==1;
    }

    /**
     * 修改收货人地址信息
     * @param consignee
     * @return
     */
    @Override
    public Boolean update(Consignee consignee) {
        Integer lines = consigneeMapper.update(consignee);
        return lines == 1;
    }
}
